package com.huiketong.cofpasgers.repository;

import com.huiketong.cofpasgers.entity.DesignCase;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface DesignCaseRepository extends JpaRepository<DesignCase,Integer> {
    @Override
    <S extends DesignCase> S save(S s);

    @Query(value = "select * from design_case where  company_id = ?1 LIMIT ?2,?3",nativeQuery = true)
    List<DesignCase> findDesignCasesByCompanyId(Integer companyId,Integer page,Integer limit);

    DesignCase findDesignCaseById(Integer id);

    @Query(value = "update design_case set title = ?1,subtitle = ?2,content = ?3,style = ?4,image = ?5 where  id = ?6",nativeQuery = true)
    @Modifying
    @Transactional
    void updateDesignCase(String title, String subtitle, String content, String style, String mainimg,Integer id);
}
